// Code generated by bpf2go; DO NOT EDIT.
//go:build 386 || amd64

package tracer

import (
	"bytes"
	_ "embed"
	"fmt"
	"io"

	"github.com/cilium/ebpf"
)

type tcptopIpKeyT struct {
	Saddr   [16]uint8
	Daddr   [16]uint8
	Mntnsid uint64
	Pid     uint32
	Name    [16]uint8
	Lport   uint16
	Dport   uint16
	Family  uint16
	_       [6]byte
}

type tcptopTrafficT struct {
	Sent     uint64
	Received uint64
}

// loadTcptop returns the embedded CollectionSpec for tcptop.
func loadTcptop() (*ebpf.CollectionSpec, error) {
	reader := bytes.NewReader(_TcptopBytes)
	spec, err := ebpf.LoadCollectionSpecFromReader(reader)
	if err != nil {
		return nil, fmt.Errorf("can't load tcptop: %w", err)
	}

	return spec, err
}

// loadTcptopObjects loads tcptop and converts it into a struct.
//
// The following types are suitable as obj argument:
//
//	*tcptopObjects
//	*tcptopPrograms
//	*tcptopMaps
//
// See ebpf.CollectionSpec.LoadAndAssign documentation for details.
func loadTcptopObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
	spec, err := loadTcptop()
	if err != nil {
		return err
	}

	return spec.LoadAndAssign(obj, opts)
}

// tcptopSpecs contains maps and programs before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type tcptopSpecs struct {
	tcptopProgramSpecs
	tcptopMapSpecs
}

// tcptopSpecs contains programs before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type tcptopProgramSpecs struct {
	IgToptcpClean *ebpf.ProgramSpec `ebpf:"ig_toptcp_clean"`
	IgToptcpSdmsg *ebpf.ProgramSpec `ebpf:"ig_toptcp_sdmsg"`
}

// tcptopMapSpecs contains maps before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type tcptopMapSpecs struct {
	GadgetMntnsFilterMap *ebpf.MapSpec `ebpf:"gadget_mntns_filter_map"`
	IpMap                *ebpf.MapSpec `ebpf:"ip_map"`
}

// tcptopObjects contains all objects after they have been loaded into the kernel.
//
// It can be passed to loadTcptopObjects or ebpf.CollectionSpec.LoadAndAssign.
type tcptopObjects struct {
	tcptopPrograms
	tcptopMaps
}

func (o *tcptopObjects) Close() error {
	return _TcptopClose(
		&o.tcptopPrograms,
		&o.tcptopMaps,
	)
}

// tcptopMaps contains all maps after they have been loaded into the kernel.
//
// It can be passed to loadTcptopObjects or ebpf.CollectionSpec.LoadAndAssign.
type tcptopMaps struct {
	GadgetMntnsFilterMap *ebpf.Map `ebpf:"gadget_mntns_filter_map"`
	IpMap                *ebpf.Map `ebpf:"ip_map"`
}

func (m *tcptopMaps) Close() error {
	return _TcptopClose(
		m.GadgetMntnsFilterMap,
		m.IpMap,
	)
}

// tcptopPrograms contains all programs after they have been loaded into the kernel.
//
// It can be passed to loadTcptopObjects or ebpf.CollectionSpec.LoadAndAssign.
type tcptopPrograms struct {
	IgToptcpClean *ebpf.Program `ebpf:"ig_toptcp_clean"`
	IgToptcpSdmsg *ebpf.Program `ebpf:"ig_toptcp_sdmsg"`
}

func (p *tcptopPrograms) Close() error {
	return _TcptopClose(
		p.IgToptcpClean,
		p.IgToptcpSdmsg,
	)
}

func _TcptopClose(closers ...io.Closer) error {
	for _, closer := range closers {
		if err := closer.Close(); err != nil {
			return err
		}
	}
	return nil
}

// Do not access this directly.
//
//go:embed tcptop_bpfel_x86.o
var _TcptopBytes []byte
